#include "sDrawStack.h"
#include "sGui.h"
#include <deque>

namespace sgui
{
namespace engine
{
	
sDrawStack::sDrawStack(sGUI& gui, sDrawSurface& surface) :
	m_gui(gui),
	m_surface(surface)
{
}

bool sDrawStack::push(const sDrawContext* context)
{
	if (context->beginDraw(m_surface))
	{
		m_stack.push(context);
		return true;
	}
	else
	{
		return false;
	}
}

void sDrawStack::pop(bool deleteContext /* = false */)
{
	if (!m_stack.empty())
	{
		m_stack.top()->endDraw(m_surface);
		if (deleteContext)
		{
			delete m_stack.top();
		}
		m_stack.pop();

		if (!m_stack.empty())
		{
			m_stack.top()->updateDraw(m_surface);
		}
	}
}

};
};